package tech.aistar.listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

/**
 * 本类用来演示:
 *
 * @author: success
 * @date: 2021/4/29 10:23 上午
 */
@WebListener
public class PathListener implements ServletContextListener {
    @Override
    public void contextInitialized(ServletContextEvent sce) {

        ServletContext application = sce.getServletContext();
        String contextPath = application.getContextPath();
        application.setAttribute("path",contextPath);
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {

    }
}
